


#pragma once

#include <iostream>


namespace gmad
{
	// copy from matlab
	static void initGammaDict(float *gamma)
	{
		gamma[0]=0.000834;
		gamma[1]=0.000984;
		gamma[2]=0.001148;
		gamma[3]=0.001328;
		gamma[4]=0.001523;
		gamma[5]=0.001733;
		gamma[6]=0.001960;
		gamma[7]=0.002203;
		gamma[8]=0.002463;
		gamma[9]=0.002740;
		gamma[10]=0.003035;
		gamma[11]=0.003347;
		gamma[12]=0.003677;
		gamma[13]=0.004025;
		gamma[14]=0.004391;
		gamma[15]=0.004777;
		gamma[16]=0.005182;
		gamma[17]=0.005605;
		gamma[18]=0.006049;
		gamma[19]=0.006512;
		gamma[20]=0.006995;
		gamma[21]=0.007499;
		gamma[22]=0.008023;
		gamma[23]=0.008568;
		gamma[24]=0.009134;
		gamma[25]=0.009721;
		gamma[26]=0.010330;
		gamma[27]=0.010960;
		gamma[28]=0.011612;
		gamma[29]=0.012286;
		gamma[30]=0.012983;
		gamma[31]=0.013702;
		gamma[32]=0.014444;
		gamma[33]=0.015209;
		gamma[34]=0.015996;
		gamma[35]=0.016807;
		gamma[36]=0.017642;
		gamma[37]=0.018500;
		gamma[38]=0.019382;
		gamma[39]=0.020289;
		gamma[40]=0.021219;
		gamma[41]=0.022174;
		gamma[42]=0.023153;
		gamma[43]=0.024158;
		gamma[44]=0.025187;
		gamma[45]=0.026241;
		gamma[46]=0.027321;
		gamma[47]=0.028426;
		gamma[48]=0.029557;
		gamma[49]=0.030713;
		gamma[50]=0.031896;
		gamma[51]=0.033105;
		gamma[52]=0.034340;
		gamma[53]=0.035601;
		gamma[54]=0.036889;
		gamma[55]=0.038204;
		gamma[56]=0.039546;
		gamma[57]=0.040915;
		gamma[58]=0.042311;
		gamma[59]=0.043735;
		gamma[60]=0.045186;
		gamma[61]=0.046665;
		gamma[62]=0.048172;
		gamma[63]=0.049707;
		gamma[64]=0.051269;
		gamma[65]=0.052861;
		gamma[66]=0.054480;
		gamma[67]=0.056128;
		gamma[68]=0.057805;
		gamma[69]=0.059511;
		gamma[70]=0.061246;
		gamma[71]=0.063010;
		gamma[72]=0.064803;
		gamma[73]=0.066626;
		gamma[74]=0.068478;
		gamma[75]=0.070360;
		gamma[76]=0.072272;
		gamma[77]=0.074214;
		gamma[78]=0.076185;
		gamma[79]=0.078187;
		gamma[80]=0.080220;
		gamma[81]=0.082283;
		gamma[82]=0.084376;
		gamma[83]=0.086500;
		gamma[84]=0.088656;
		gamma[85]=0.090842;
		gamma[86]=0.093059;
		gamma[87]=0.095307;
		gamma[88]=0.097587;
		gamma[89]=0.099899;
		gamma[90]=0.102242;
		gamma[91]=0.104616;
		gamma[92]=0.107023;
		gamma[93]=0.109462;
		gamma[94]=0.111932;
		gamma[95]=0.114435;
		gamma[96]=0.116971;
		gamma[97]=0.119538;
		gamma[98]=0.122139;
		gamma[99]=0.124772;
		gamma[100]=0.127438;
		gamma[101]=0.130136;
		gamma[102]=0.132868;
		gamma[103]=0.135633;
		gamma[104]=0.138432;
		gamma[105]=0.141263;
		gamma[106]=0.144128;
		gamma[107]=0.147027;
		gamma[108]=0.149960;
		gamma[109]=0.152926;
		gamma[110]=0.155926;
		gamma[111]=0.158961;
		gamma[112]=0.162029;
		gamma[113]=0.165132;
		gamma[114]=0.168269;
		gamma[115]=0.171441;
		gamma[116]=0.174647;
		gamma[117]=0.177888;
		gamma[118]=0.181164;
		gamma[119]=0.184475;
		gamma[120]=0.187821;
		gamma[121]=0.191202;
		gamma[122]=0.194618;
		gamma[123]=0.198069;
		gamma[124]=0.201556;
		gamma[125]=0.205079;
		gamma[126]=0.208637;
		gamma[127]=0.212231;
		gamma[128]=0.215861;
		gamma[129]=0.219526;
		gamma[130]=0.223228;
		gamma[131]=0.226966;
		gamma[132]=0.230740;
		gamma[133]=0.234551;
		gamma[134]=0.238398;
		gamma[135]=0.242281;
		gamma[136]=0.246201;
		gamma[137]=0.250158;
		gamma[138]=0.254152;
		gamma[139]=0.258183;
		gamma[140]=0.262251;
		gamma[141]=0.266356;
		gamma[142]=0.270498;
		gamma[143]=0.274677;
		gamma[144]=0.278894;
		gamma[145]=0.283149;
		gamma[146]=0.287441;
		gamma[147]=0.291771;
		gamma[148]=0.296138;
		gamma[149]=0.300544;
		gamma[150]=0.304987;
		gamma[151]=0.309469;
		gamma[152]=0.313989;
		gamma[153]=0.318547;
		gamma[154]=0.323143;
		gamma[155]=0.327778;
		gamma[156]=0.332452;
		gamma[157]=0.337164;
		gamma[158]=0.341914;
		gamma[159]=0.346704;
		gamma[160]=0.351533;
		gamma[161]=0.356400;
		gamma[162]=0.361307;
		gamma[163]=0.366253;
		gamma[164]=0.371238;
		gamma[165]=0.376262;
		gamma[166]=0.381326;
		gamma[167]=0.386429;
		gamma[168]=0.391572;
		gamma[169]=0.396755;
		gamma[170]=0.401978;
		gamma[171]=0.407240;
		gamma[172]=0.412543;
		gamma[173]=0.417885;
		gamma[174]=0.423268;
		gamma[175]=0.428690;
		gamma[176]=0.434154;
		gamma[177]=0.439657;
		gamma[178]=0.445201;
		gamma[179]=0.450786;
		gamma[180]=0.456411;
		gamma[181]=0.462077;
		gamma[182]=0.467784;
		gamma[183]=0.473531;
		gamma[184]=0.479320;
		gamma[185]=0.485150;
		gamma[186]=0.491021;
		gamma[187]=0.496933;
		gamma[188]=0.502886;
		gamma[189]=0.508881;
		gamma[190]=0.514918;
		gamma[191]=0.520996;
		gamma[192]=0.527115;
		gamma[193]=0.533276;
		gamma[194]=0.539479;
		gamma[195]=0.545724;
		gamma[196]=0.552011;
		gamma[197]=0.558340;
		gamma[198]=0.564712;
		gamma[199]=0.571125;
		gamma[200]=0.577580;
		gamma[201]=0.584078;
		gamma[202]=0.590619;
		gamma[203]=0.597202;
		gamma[204]=0.603827;
		gamma[205]=0.610496;
		gamma[206]=0.617207;
		gamma[207]=0.623960;
		gamma[208]=0.630757;
		gamma[209]=0.637597;
		gamma[210]=0.644480;
		gamma[211]=0.651406;
		gamma[212]=0.658375;
		gamma[213]=0.665387;
		gamma[214]=0.672443;
		gamma[215]=0.679542;
		gamma[216]=0.686685;
		gamma[217]=0.693872;
		gamma[218]=0.701102;
		gamma[219]=0.708376;
		gamma[220]=0.715694;
		gamma[221]=0.723055;
		gamma[222]=0.730461;
		gamma[223]=0.737910;
		gamma[224]=0.745404;
		gamma[225]=0.752942;
		gamma[226]=0.760525;
		gamma[227]=0.768151;
		gamma[228]=0.775822;
		gamma[229]=0.783538;
		gamma[230]=0.791298;
		gamma[231]=0.799103;
		gamma[232]=0.806952;
		gamma[233]=0.814847;
		gamma[234]=0.822786;
		gamma[235]=0.830770;
		gamma[236]=0.838799;
		gamma[237]=0.846873;
		gamma[238]=0.854993;
		gamma[239]=0.863157;
		gamma[240]=0.871367;
		gamma[241]=0.879622;
		gamma[242]=0.887923;
		gamma[243]=0.896269;
		gamma[244]=0.904661;
		gamma[245]=0.913099;
		gamma[246]=0.921582;
		gamma[247]=0.930111;
		gamma[248]=0.938686;
		gamma[249]=0.947307;
		gamma[250]=0.955973;
		gamma[251]=0.964686;
		gamma[252]=0.973445;
		gamma[253]=0.982251;
		gamma[254]=0.991102;
		gamma[255]=1.000000;

	}



    class dict {
    public:
        static dict* Instance(){
            static dict* s_dict = new dict();
            return s_dict;
        }
        static void initGamma(){
			gamma = new float[256];
			initGammaDict(gamma);
			std::cout<<"initing gamma Dict"<<std::endl;
        }
        static float query(int Key){
        	if(gamma==NULL){
        		std::cout<<"gamma Dict not inited"<<std::endl;
        		return -1.0 ;
        	}
        	return gamma[Key];
        }
        static float* head(){
        	return dict::gamma;
        }
    private:
        dict(){}                            // Constructor
        dict(dict const&);          // Don't Implement
        void operator=(dict const&);        // Don't implement


    private:
        static float *gamma;
    };



    float *dict::gamma = NULL ;

}




